﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Admin_InterviewerManagement : System.Web.UI.Page
{
    AddminMethord AM = new AddminMethord();
    protected void Page_Load(object sender, EventArgs e)
    {
        viewallinterview();
    }
    public void viewallinterview() {
        DataTable tb = AM.AdminviewAllInterviewer();
        gvwInterviewer.DataSource = tb.DefaultView;
        gvwInterviewer.DataBind();
        for (int i = 0; i < tb.Rows.Count;i++ )
        {
            gvwInterviewer.Rows[i].Cells[4].Text = tb.Rows[i]["BirthOfDate"].ToString().Substring(0,tb.Rows[i]["BirthOfDate"].ToString().IndexOf(" "));
        }
        
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        if (ddlSearch.SelectedItem.ToString().Equals("InterviewerID"))
        {
            DataTable tb =  AM.AdminSearchByInterviewID(txtsearch.Text);
            gvwInterviewer.DataSource = tb.DefaultView;
            gvwInterviewer.DataBind();
            for (int i = 0; i < tb.Rows.Count; i++)
            {
                gvwInterviewer.Rows[i].Cells[4].Text = tb.Rows[i]["BirthOfDate"].ToString().Substring(0, tb.Rows[i]["BirthOfDate"].ToString().IndexOf(" "));
            }
        }
        else {
            DataTable tb = AM.AddminsearchByFulName(txtsearch.Text);
            gvwInterviewer.DataSource = tb.DefaultView;
            gvwInterviewer.DataBind();
            for (int i = 0; i < tb.Rows.Count; i++)
            {
                gvwInterviewer.Rows[i].Cells[4].Text = tb.Rows[i]["BirthOfDate"].ToString().Substring(0, tb.Rows[i]["BirthOfDate"].ToString().IndexOf(" "));
            }
        }           
           
    }
}